public class Team implements Comparable<Team> {
    private String name;
    private int played;
    private int won;
    private int drawn;
    private int lost;
    private int goalsFor;
    private int goalsAgainst;
    private int points;

    public Team(String name) {
        this.name = name;
    }

    public void updateStats(int goalsFor, int goalsAgainst) {
        this.played++;
        this.goalsFor += goalsFor;
        this.goalsAgainst += goalsAgainst;

        if (goalsFor > goalsAgainst) {
            this.won++;
            this.points += 3;
        } else if (goalsFor < goalsAgainst) {
            this.lost++;
        } else {
            this.drawn++;
            this.points++;
        }
    }

    public int getGoalDifference() {
        return goalsFor - goalsAgainst;
    }

    @Override
    public int compareTo(Team other) {
        if (this.points != other.points) {
            return Integer.compare(other.points, this.points);
        }
        if (this.getGoalDifference() != other.getGoalDifference()) {
            return Integer.compare(other.getGoalDifference(), this.getGoalDifference());
        }
        return Integer.compare(other.goalsFor, this.goalsFor);
    }

    @Override
    public String toString() {
        return String.format("%-15s %2d %2d %2d %2d %2d %2d %3d %2d",
                name, played, won, drawn, lost, goalsFor, goalsAgainst, getGoalDifference(), points);
    }

    // Getters
    public String getName() { return name; }
    public int getPlayed() { return played; }
    public int getWon() { return won; }
    public int getDrawn() { return drawn; }
    public int getLost() { return lost; }
    public int getGoalsFor() { return goalsFor; }
    public int getGoalsAgainst() { return goalsAgainst; }
    public int getPoints() { return points; }
}

